/**
 * Created by Administrator on 2016/8/1.
 */
//倒计时事件
window.onload = function() {
    var target_time = new Date('2016-08-02 17:50:00'.replace(/-/g, '/')).getTime();
    var now_time = new Date().getTime();
    var t = Math.floor((target_time - now_time) / 1000);
    var MIN = 60;
    var HOUR = MIN * 60;
    var DAY = HOUR * 24;

    function num(n) {
        var str = '0' + (n > 0 ? n : 0);
        return str.substr(-2);
    };
    function timer() {
        var days = Math.floor(t / DAY);
        var hours = Math.floor(t % DAY / HOUR);
        var minutes = Math.floor(t % HOUR / MIN);
        var seconds = Math.floor(t % MIN);
        var ms = Math.floor(100 / seconds) * 100;
        if (t < 60) {
            //小于60秒的
            var content = '00天00时00分00秒00';
        } else if (days <= 1) {
            //如果是今天的就只显示小时，分钟和秒
            var content = num(days) + "天" + num(hours) + "时" + num(minutes) + "分" + num(seconds) + "秒" + num(ms);

        } else {
            //如果不符合上面两个，就显示所有的
            var content = num(days) + "天" + num(hours) + "时" + num(minutes) + "分" + num(seconds) + "秒" + num(ms);
        }
        document.getElementById("timer").innerHTML = content;
    };
    function m() {
        timer();
        setTimeout(function () {
            t -= 1;
            timer();
            if (t > 0) {
                setTimeout(arguments.callee, 1000);
            }
        }, 1000);
    };
    m();

    //点击区域中的移入移出
    $('.main-center-e').mouseover(function () {
        $('.main-center-yin').css({display: 'block'});
    })
    $('.main-center-e').mouseout(function () {
        $('.main-center-yin').css({display: 'none'});
    })
    //点击事件的隐藏事件
    $(function () {
        var trun = true;
        $('.five-2').click(function () {
            if (trun) {
                $('.five').css('height', "112px");
                $('.five-1').css('height', "72px");
                trun = false
            } else {
                $('.five').css("height", "59px");
                $('.five-1').css("height", "18px");
                $('.five-1').css("overflow", "hidden");
                $('.five').css("overflow", "hidden");
                trun = true;
            }
        })

        //图片点击事件 滑入滑出开关 大小图转换
        $('.one').click(function () {
            if (trun == true) {
                $('.one-1').slideDown();
                trun = false;
            } else {
                $('.one-1').slideUp();
                trun = true;
            }
        })
        $('.one-1').click(function () {
            $('.one-1').slideUp();
        })
        $('.two').click(function () {
            if (trun == true) {
                $('.two-1').slideDown();
                trun = false;
            } else {
                $('.two-1').slideUp();
                trun = true;
            }
        })
        $('.two-1').click(function () {
            $('.two-1').slideUp();
        })
        $('.three').click(function () {
            if (trun == true) {
                $('.three-1').slideDown();
                trun = false;
            } else {
                $('.three-1').slideUp();
                trun = true;
            }
        })
        $('.three-1').click(function () {
            $('.three-1').slideUp();
        })
    });
    //tab切换
    $(".tab li").each(function (index) {
        $(this).click(function () {
            $('.tab li').not(index).removeClass('six-li').eq($(this).index()).addClass('six-li');
            $('.img-y-1').not(index).css('display', 'none').eq($(this).index()).css('display', 'block');
        });
    });
    $('.img-y-1').click(function () {
        $('.img-y-1').slideUp();
    })
    //图片置顶 到一定高度后的移入移出
    setInterval(function () {
        var y = $(document).scrollTop();
        console.log(y);
        if (y > 650) {
            $('.wrapper').css('display', 'block');
        } else {
            $('.wrapper').css('display', 'none');
        }
    })
    //tab切换
    var aLi = document.querySelector('#cc');
    var bLi = document.querySelector('#aa');
    var five = document.querySelector('#five');
    var center = document.querySelector('.home-center');
    bLi.addEventListener('click', function () {
        bLi.style.borderTop = '5px solid #ef2f23';
        bLi.style.borderBottom = '1px solid #fff';
        bLi.style.background = "#fff";
        center.style.display = 'none';
        five.style.display = 'block';
        aLi.style.background = "#f6f6f6";
        aLi.style.borderTop = "5px solid #f6f6f6";
        aLi.style.borderBottom = '1px solid #e5e5e5';
    });
    aLi.addEventListener('click', function () {
        aLi.style.borderTop = '5px solid #ef2f23';
        aLi.style.borderBottom = '1px solid #fff';
        aLi.style.background = "#fff";
        center.style.display = 'block';
        five.style.display = 'none';
        bLi.style.background = "#f6f6f6";
        bLi.style.borderTop = "5px solid #f6f6f6";
        bLi.style.borderBottom = '1px solid #e5e5e5';
    });
    //tab切换
    var box = document.querySelector('#and');
    var min = document.querySelector('#end');
    var five = document.querySelector('#five');
    var center = document.querySelector('.home-center');
    min.addEventListener('click', function () {
        min.style.borderTop = '5px solid #ef2f23';
        min.style.borderBottom = '1px solid #fff';
        min.style.background = "#fff";
        center.style.display = 'none';
        five.style.display = 'block';
        box.style.background = "#f6f6f6";
        box.style.borderTop = "5px solid #f6f6f6";
        box.style.borderBottom = '1px solid #e5e5e5';
    });
    box.addEventListener('click', function () {
        box.style.borderTop = '5px solid #ef2f23';
        box.style.borderBottom = '1px solid #fff';
        box.style.background = "#fff";
        center.style.display = 'block';
        five.style.display = 'none';
        min.style.background = "#f6f6f6";
        min.style.borderTop = "5px solid #f6f6f6";
        min.style.borderBottom = '1px solid #e5e5e5';
    });
    //点击事件的隐藏
    $(function () {
        $('.out-1').click(function () {
            $('#one').css('display', "block");
        })
        $('.home-center-three').mouseover(function (){
            $('#one').css('display', "none");
        })
    })
    $(function () {
        $('.out-2').click(function () {
            $('#two').css('display', "block");
        })
        $('.home-center-three').mouseover(function (){
            $('#two').css('display', "none");
        })
    })
    $(function () {
        $('.out-3').click(function () {
            $('#four').css('display', "block");
        })
        $('.home-center-two').mouseover(function (){
            $('#four').css('display', "none");
        })
    })
    //图片置顶 到一定高度后的移入移出
    setInterval(function () {
        //高度的改变
        var n = $(document).scrollTop();
        console.log(n);
        if (n > 180) {
            $('.flex-four').css('display', 'block');
        } else {
            $('.flex-four').css('display', 'none');
        } //宽度的改变
    })



















}